package com.sky.mapper;


import com.github.pagehelper.Page;
import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersCancelDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.entity.TakeoutOrder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;

@Mapper
public interface OrderMapper {
    List<TakeoutOrder> pageOrder(LocalDateTime beginTime, LocalDateTime endTime, String number, Integer status, String phone);

    Integer countOrder(LocalDateTime beginTime, LocalDateTime endTime, String number, String status, String phone);

    void deliveryOrder(String id);

    void confirmOrder(TakeoutOrder takeoutOrder);

    void rejectOrder(TakeoutOrder takeoutOrder);

    TakeoutOrder getDetails(String id);

    void cancelOrder(OrdersCancelDTO takeoutOrder);

    Integer countConfirmed();

    Integer countDeliveryInProgress();

    Integer countToBeConfirmeds();

    void complete(String id);

    //用户下单
    void insert(Orders orders);

    //历史订单查询
    Page<Orders> pageQuery(OrdersPageQueryDTO ordersPageQueryDTO);

    // 查询订单详情
    Orders getOrderById(Long id);

    //取消订单
    void cancelOrderById(Long id);

    void updateStatusAndOrderTime(Orders orders);
    // 超时订单
    @Select("select * from orders where status=#{pendingPayment} and order_time<#{outTimeOrders};")
    List<Orders> getStatusAndOrderTime(Integer pendingPayment, LocalDateTime outTimeOrders);

    BigDecimal sumByCondition(Integer status, LocalDate localDate);

    Integer countByMap(HashMap<Object, Object> param);

    List<GoodsSalesDTO> topTen(LocalDate begin, LocalDate end);
}
